const { User } = require('../../model/user');
module.exports = async(req, res) => {
    req.app.locals.currentLink = 'user';
    let id = req.query.id;
    if (id) {
        const user = await User.findOne({ _id: id });
        res.render('admin/user-edit', { user, link: `/admin/user-edit?id=${id}`, button: '修改', message: req.query.message });
    } else {
        res.render('admin/user-edit', { link: '/admin/user-add', button: '新增', message: req.query.message });
    }
}